package com.windowes.weichang.controller.platform;

import com.windowes.weichang.access.AccessLimit;
import com.windowes.weichang.common.ServerResponse;
import com.windowes.weichang.dto.DeptDTO;
import com.windowes.weichang.service.AgentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.rmi.ServerError;

/***
 *
 * @author: yangqing
 * @email: qing.yang@bangdao-tech.com
 * @createTime: 2018/7/28 下午2:43
 * @description: 城市代理商
 *
 **/
@RestController
@RequestMapping("agent")
public class AgentController {


    @Autowired
    AgentService agentService;

    @AccessLimit(manageUser = true)
    @PostMapping("addOrUpdate")
    public ServerResponse addOrUpdate(@RequestBody DeptDTO dto) {
        return agentService.addOrUpdate(dto);
    }

    @AccessLimit(manageUser = true)
    @GetMapping("list")
    public ServerResponse list(@RequestParam(value = "pageNo", defaultValue = "1") int pageNo,
                               @RequestParam(value = "pageSize", defaultValue = "15") int pageSize) {
        return agentService.list(pageNo, pageSize);
    }


    @GetMapping("district")
    public ServerResponse district() {
        return agentService.district();
    }

    @GetMapping("user")
    public ServerResponse user(Integer id) {
        return agentService.user(id);
    }


}
